package com.mate.cloud.chain.service;

import com.mate.cloud.chain.domain.User;
import com.mate.cloud.chain.handler.DiscountHandler;
import org.springframework.stereotype.Service;

/**
 * 使用责任链
 * @author:         MI
 * @email:          448341911@qq.com
 * @createTime:     2025/1/27 14:09
 * @updateUser:     MI
 * @updateTime:     2025/1/27 14:09
 * @updateRemark:   修改内容
 * @version:        v1.0
 */
@Service
public class DiscountService {

    private final DiscountHandler discountHandler;

    public DiscountService(DiscountHandler discountHandler) {
        this.discountHandler = discountHandler;
    }

    public double calculateDiscount(double amount, User user) {
        return discountHandler.applyDiscount(amount, user);
    }
}
